package cn.ctodb.divination.action;

import cn.ctodb.divination.service.*;
import cn.ctodb.divination.service.dto.WuGe;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;

/**
 * Created by cc on 2017/2/5.
 */
@Controller
public class SmAction {

    @Inject
    private WuGeService wuGeService;
    @Inject
    private HzwxService hzwxService;
    @Inject
    private BaseService baseService;

    @RequestMapping("/sm/{xing}/{ming}/{xingbie}/{xuexing}/{scbz}")
    public String sm(@PathVariable String xing, @PathVariable String ming, @PathVariable String xingbie, @PathVariable String xuexing, @PathVariable String scbz, ModelMap modelMap) {
        WuGe wuGe = wuGeService.js(xing, ming);
        modelMap.put("wuge", wuGe);
        modelMap.put("zywx", hzwxService.zywx(xing, ming).toString());
        String[] bazi = baseService.exec(scbz);
        modelMap.put("bazi", bazi);
        modelMap.put("tgdzwx", baseService.tgdzwx(bazi));
        modelMap.put("nayin_ygz", baseService.nayin(bazi[0] + bazi[1]));
        return "sm";
    }

    @ResponseBody
    @RequestMapping("/wuge/js/{xing}/{ming}")
    public WuGe js(@PathVariable String xing, @PathVariable String ming) {
        return wuGeService.js(xing, ming);
    }

}
